package cn.yunhe.services.impl;

import cn.yunhe.dao.IPointDao;
import cn.yunhe.entity.Course;
import cn.yunhe.entity.Lib;
import cn.yunhe.entity.Point;
import cn.yunhe.services.IPointServices;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by ${王雪丹} on 2018/5/24.
 */
@Service("pointServices")
public class PointServicesImpl implements IPointServices {
    @Resource
    private IPointDao pointDao;
    @Override
    public Page queryListLikePoint(Map<String, Object> cond) {
        Page page = new Page();
        page.setTotal(pointDao.getLikeCountPoint(cond));
        int pageSize = Integer.parseInt(String.valueOf(cond.get("pageSize")));
        //当前页
        int curpageNum = Integer.parseInt(String.valueOf(cond.get("pageNum")));
        page.setPageNum(curpageNum);
        //将条件传递给pageHelper
        page = PageHelper.startPage(curpageNum,pageSize);
        List<Point>list=pointDao.getLikePoint(cond);
        return page;
    }
    /**
     * 根据id查询该知识点的信息
     * @param id
     * @return
     */
    @Override
    public List<Point> getPointServices(int id) {
        return pointDao.getPointId(id);
    }

    /**
     * 查询全部知识点
     *
     * @return
     */
    @Override
    public List<Point> findPoint() {
        return pointDao.findPoint();
    }

    /**
     * 根据题库id查看所属所有知识点
     * @param lib_id
     * @return
     */
    @Override
    public List<Point> getPointLib(int lib_id) {
        return pointDao.getPointLib(lib_id);
    }
    /**
     * 添加知识点
     * @param point
     * @return
     */
    @Override
    public int addPoint(Point point) {

        return pointDao.addPoint(point);
    }

    @Override
    public Point getById(Point point) {

        return pointDao.getById(point);
    }

    @Override
    public int updatePoint(Point point)
    {
        return pointDao.updatePoint(point);
    }

    @Override
    public List<Point> getLibPoint(int id) {
        return pointDao.getPointLib(id);
    }

    @Override
    public List<Lib> getAllLib() {
        return pointDao.getAllLib();
    }

    @Override
    public List<Course> getAllCourse() {
        return pointDao.getAllCourse();
    }

    public IPointDao getPointDao() {
        return pointDao;
    }

    public void setPointDao(IPointDao pointDao) {
        this.pointDao = pointDao;
    }
}
